﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twitter;
using System.Configuration;
using System.Diagnostics;

namespace FriendsNearbyBot
{
	class Program
	{
		static void Main(string[] args)
		{
            // 1. Mutex created in global name space. See http://msdn2.microsoft.com/en-us/library/ms682411.aspx
            // 2. Guid for FriendsNearbyBot Application
            var runner = new SingleInstanceRunner(@"Global\121827C4-301E-404b-A6BD-5C75BB1EA3E2", RunBot, BotAlreadyRunning);

            runner.Run();

            if (Debugger.IsAttached)
            {
                Console.ReadLine();
            }
        }

        static void RunBot()
        {
			BotProcessor processor = new BotProcessor(
				ConfigurationManager.AppSettings["botUser"],
				ConfigurationManager.AppSettings["botPassword"],
				new Greeter(),	
			    new DefaultProcessor(), 
				new HelpProcessor(),
                new HiProcessor(),
                new NearbyNotifierProcessor(),
                new FriendsProcessor(),
                new PeopleNearbyProcessor(), 
                new FriendsQueryProcessor(),
                new PingProcessor(),
                new UpdateLocationProcessor()
                );

			processor.Run();

			Console.WriteLine("Done");
		}

        static void BotAlreadyRunning()
        {
            Console.WriteLine("This application is already running");
        }
	}
}
